package com.ctgu.demo.controller;

import com.ctgu.demo.entity.Dessert;
import com.ctgu.demo.service.DessertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
@RestController
@RequestMapping("/desserts")
public class DessertsController {

    @Autowired
    private DessertService dessertService;

    @RequestMapping("/getDessertOne/{dessertId}")
    public Dessert getBook(@PathVariable("dessertId") String dessertId){
        return dessertService.getById(dessertId);
    }
}
